package org.lwd.datalink.api.util.scan;

import lombok.extern.slf4j.Slf4j;

/**
 * Class path 类文件扫描器
 *
 * @author lwd
 */
@Slf4j
public class ClasspathClassScanner implements ClassScanner {

    @Override
    public Class<?> scan(String className) {
        try {
            //必须从线程上线文获取classloader，即：取插件的classloader，不能用Class.getClassLoader
            return Thread.currentThread().getContextClassLoader().loadClass(className);
        } catch (ClassNotFoundException e) {
            log.error("ERROR ## can not found this class ,the name = " + className);
        }

        return null;
    }

}
